
//
// 130517 - AH - Created.
//

package org.socratons.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.japril.jutil.CharArrayPrintWriter;

final class SocData
{
  final String id;
  String who=null;
  final Map<String, List<String>> bisons=new HashMap<String, List<String>>();
  
  void addBisonData(String ctx, String data)
  {
    List<String> l=bisons.get(ctx);
    if (l==null)
    {
      l=new ArrayList<String>();
      bisons.put(ctx, l);
    }
    l.add(data);
  }
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param id  Socraton id.
   * @param who Who.
   */
  SocData(Object id, String who){ this.id=id.toString(); this.who=who; }
  
  @Override
  public String toString()
  {
    StringBuilder sb=new StringBuilder();
    
    CharArrayPrintWriter capw=new CharArrayPrintWriter();
    
    sb.append("id=").append(id).append(", who=").append(who);
    capw.println(sb);
    for (Map.Entry<String, List<String>> e : bisons.entrySet())
    {
      String ctx=e.getKey();
      capw.println("  "+ctx);
      List<String> l=e.getValue();
      for (String b : l)
      {
        capw.println("    "+b);
      }
    }
    
    return capw.toString();
  }
  
}